<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.48">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bb0e03}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #0013fe}
span.s3 {color: #0000ff}
span.s4 {color: #000ebe}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>BufMax<span class="Apple-tab-span">	</span></b></span><b>UGen detects the largest value (and its position) in a Buffer</b></p>
<p class="p2"><br></p>
<p class="p3"><b># val, index = BufMax.kr(bufnum, gate)</b></p>
<p class="p2"><br></p>
<p class="p3">Finds the largest value in a <a href="SC://Buffer"><span class="s2">Buffer</span></a>, and outputs the <i>value</i> and the <i>index</i>.</p>
<p class="p2"><br></p>
<p class="p3">You don't need to make use of the <b>gate</b> control: if you do use it, the calculation is only performed when gate&gt;0.</p>
<p class="p2"><br></p>
<p class="p3">(Note: doesn't currently handle multichannel buffers in any clever way, treats them as if they were single-channel.)</p>
<p class="p2"><br></p>
<p class="p3">See also: <a href="BufMin.html"><span class="s3">BufMin</span></a></p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p3"><b>Example</b></p>
<p class="p2"><br></p>
<p class="p4">s.boot;</p>
<p class="p5"><br></p>
<p class="p4">b = <span class="s4">Buffer</span>.alloc(s, 100);</p>
<p class="p4">b.zero;</p>
<p class="p4">b.set(33, 1.034);</p>
<p class="p6">// This should detect the 33rd value as the highest...</p>
<p class="p4">x = {<span class="s4">BufMax</span>.kr(b).poll}.play;</p>
<p class="p5"><br></p>
<p class="p6">// ...until we set a new winner...</p>
<p class="p4">b.set(74, 1.038);</p>
</body>
</html>
